package models;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import play.db.jpa.Model;

@Entity
@Table(name = "Components_Users", uniqueConstraints = { @UniqueConstraint(columnNames = {
		"user_id", "component_id" }) })
public class ComponentUser extends Model {

	public boolean isMember;

	@ManyToOne
	@JoinColumn(name = "user_id")
	public User user;

	@ManyToOne
	@JoinColumn(name = "component_id")
	public Component component;

	/**
	 * constructs a new ComponentUser object.
	 * 
	 * @param isMember
	 * @param user
	 * @param component
	 */
	public ComponentUser(boolean isMember, User user, Component component) {
		super();
		this.isMember = isMember;
		this.user = user;
		this.component = component;
	}

}
